<template>

  <div>
    <!-- 幻灯片 开始 -->
    <client-only>
      <el-carousel :interval="5000" arrow="always" :height="bannerHeight + 'px'" class="bannerImg">
        <el-carousel-item v-for="banner in bannerList" :key="banner.id">
          <img :src="banner.imageUrl"  :alt="banner.title"  class="bannerImg"/>
        </el-carousel-item>
      </el-carousel>
    </client-only>
    <!-- 幻灯片 结束 -->

     <div id="aCoursesList">
      <!-- 番剧 开始 -->
      <div>
        <section class="container">
          <header class="comm-title">
            <h2 class="tac">
              <span class="c-333">热门作品</span>
            </h2>
          </header>
          <div>
            <article class="comm-course-list">
              <ul class="of" id="bna">
                <li v-for="course in courseList" :key="course.id">
                  <div class="cc-l-wrap">
                    <section class="course-img">
                      <img
                        :src="course.cover"
                        class="img-responsive"
                        :alt="course.title"
                      >
                      <div class="cc-mask">
                        <a :href="'/course/'+course.id" title="开始观看" class="comm-btn c-btn-1">开始观看</a>
                      </div>
                    </section>
                    <h3 class="hLh30 txtOf mt10">
                      <a :href="'/course/'+course.id" title="course.title" class="course-title fsize18 c-333">{{course.title}}</a>
                    </h3>
                    <section class="mt10 hLh20 of">
<!--                      <span class="fr jgTag bg-green">-->
<!--                        <i class="c-fff fsize12 f-fA">{{ Number(course.price) === 0 ? '免费' :'¥' + course.price.toFixed(2) }}</i>-->
<!--                      </span>-->
                      <span class="fl jgAttr c-ccc f-fA">
                        <i class="c-999 f-fA">{{course.buyCount}}人收藏</i>
                        |
                        <i class="c-999 f-fA">{{course.viewCount}}观看</i>
                      </span>
                    </section>
                  </div>
                </li>
              </ul>
              <div class="clear"></div>
            </article>
            <section class="tac pt20">
              <a href="/course" title="全部番剧" class="comm-btn c-btn-2">全部番剧</a>
            </section>
          </div>
        </section>
      </div>
      <!-- 番剧 结束 -->
      <!-- 作者 开始 -->
      <div>
        <section class="container">
          <header class="comm-title">
            <h2 class="tac">
              <span class="c-333">知名作者</span>
            </h2>
          </header>
          <div>
            <article class="i-teacher-list">
              <ul class="of">
                <li v-for="teacher in teacherList" :key="teacher.id">
                  <section class="i-teach-wrap">
                    <div class="i-teach-pic">
                      <a :href="'/teacher/'+teacher.id" :title="teacher.name">
                        <img :alt="teacher.name" :src="teacher.avatar">
                      </a>
                    </div>
                    <div class="mt10 hLh30 txtOf tac">
                      <a :href="'/teacher/'+teacher.id" :title="teacher.name" class="fsize18 c-666">{{teacher.name}}</a>
                    </div>
                    <div class="hLh30 txtOf tac">
                      <span class="fsize14 c-999">{{teacher.career}}</span>
                    </div>
                    <div class="mt15 i-q-txt">
                      <p
                        class="c-999 f-fA"
                      >{{teacher.intro}}</p>
                    </div>
                  </section>
                </li>
              </ul>
              <div class="clear"></div>
            </article>
            <section class="tac pt20">
              <a href="/teacher" title="全部作者" class="comm-btn c-btn-2">全部作者</a>
            </section>
          </div>
        </section>
      </div>
      <!-- /作者 结束 -->
    </div>
  </div>
</template>

<script>
import banner from '@/api/banner'
export default {
  data () {
    return {
      bannerHeight: 740,
      swiperOption: {
        //配置分页
        pagination: {
          el: '.swiper-pagination'//分页的dom节点
        },
        //配置导航
        navigation: {
          nextEl: '.swiper-button-next',//下一页dom节点
          prevEl: '.swiper-button-prev'//前一页dom节点
        }
      },
      bannerList:[],
      teacherList:[],
      courseList:[]
    }
  },
  mounted() {

  },
  created(){
    this.getBannerList()
    this.getTeatherInfo()
  },
  methods:{
    getBannerList(){
      banner.getBannerList()
      .then(response=>{
        this.bannerList=response.data.data.list//axios返回的对象有一个data,后端自定义Result对象也有个data
      })
    },
    getTeatherInfo(){
      banner.getIndexInfo()
      .then(response=>{
        this.teacherList=response.data.data.teacherList
        this.courseList=response.data.data.courseList
      })
    },
  },
}
</script>
<style>
  .bannerImg{
    margin: 0 auto;
    width: 1400px;
    height: 740px;
  }

</style>
